#ifndef DISCOBASE_H
#define DISCOBASE_H
#include <string>
#include <vector>
#include <utility>
#include <map>
#include "article.h"

namespace client_server {

    	struct DatabaseException {
		int id;
	};
	
	class DiscoBase {

	public:
		/* Create/setups the database */
		DiscoBase();
		
		/* Kills the database */
		~DiscoBase();
		
		/* Creates a new newsgroup. Throws exception if newsgroup already exists */
		void create_newsgroup(std::string name) throw(DatabaseException);
		
		/* Deletes a newsgroup. Throws exception if newsgroup does not exist */
		void delete_newsgroup(int group_id) throw(DatabaseException);
		
		/* Returns a vector with pairs of all newsgroupId + newsgroup name. */
		std::vector<std::pair<int, std::string> > list_newsgroups();		
		
		/* Creates a new article. Throws exception if newsgroup does not exist. */
    		void create_article(int group_id, std::string name, std::string author, std::string content) throw(DatabaseException);
    		
    		/* Deletes an article. Throws exception if newsgroup or article does not exist. */
		void delete_article(int group_id, int art_id) throw(DatabaseException);
		
		/* Returns a vector with pairs of all articleId + article name or empty vector if no articles exists in the newsgroup. */
		std::vector<std::pair<int, std::string> > list_articles(int group_id) throw(DatabaseException);
		
		/* Returns an article object with the requested article. Throws exception if newsgroup or article does not exist. */
		Article get_article(int group_id, int art_id) throw(DatabaseException);		
    	private:
    		std::vector<std::pair<int, std::string> > newsgroups;
    		int maxIndex;
	};	


	
}



#endif
